Skip to content

all: add calloptions and handlercontext#86

Merged
tsubakiky merged 3 commits intomainfrom
client-handler-call-option
May 16, 2025
Merged

all: add calloptions and handlercontext#86
tsubakiky merged 3 commits intomainfrom
client-handler-call-option

Conversation

@tsubakiky
Copy link
Copy Markdown
Collaborator

@tsubakiky tsubakiky commented May 16, 2025

This pull request introduces significant updates to enhance call configuration flexibility and improve handler functionality in the conformance framework. The key changes include the introduction of a new CallOptions class for managing call-specific options like timeouts and abort events, updates to handler methods to include a HandlerContext for richer context management, and adjustments to client and server implementations to integrate these enhancements.

Call Configuration Enhancements:

  • Added a new CallOptions class in src/connect/call_options.py to encapsulate per-call configuration, including timeout and abort event support. This provides a cleaner and more flexible way to manage call-specific options.
  • Updated the Client class in src/connect/client.py to accept CallOptions in both _call_unary and _call_stream methods, enabling the use of the new configuration options.

Handler Context Integration:

  • Introduced HandlerContext to handler methods in conformance/gen/connectrpc/conformance/v1/conformancev1connect/service_connect.py, allowing access to additional context like remaining timeout.
  • Updated server-side handlers in conformance/server.py to utilize HandlerContext for calculating timeout values dynamically and to improve request handling. [1] [2] [3]

Refactoring and Interceptor Updates:

  • Replaced Interceptor with HandlerInterceptor in examples/server.py to align with the new handler context implementation, ensuring compatibility with the updated call flow.
  • Adjusted the wrap_unary method in examples/server.py to pass HandlerContext to the next function in the interceptor chain.

Streamlining Call Usage:

  • Refactored StreamRequest usage in conformance/client_runner.py to separate CallOptions from the request object, improving readability and modularity. [1] [2] [3]

These changes collectively enhance the flexibility, maintainability, and clarity of the conformance framework while introducing new capabilities for managing call-specific configurations.

@tsubakiky tsubakiky merged commit ff9d8b2 into main May 16, 2025
2 checks passed
@tsubakiky tsubakiky deleted the client-handler-call-option branch May 16, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants